home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <sys/time.h>
- #include <math.h>
- #include "conv.h"
-
- /* --------- The following definitions change
- according to precision required -------- */
-
-
- #ifdef SINGLE /* complex single precision */
-
- typedef float this_variable;
- typedef float this_real;
-
- #define OPS_PER_ITER 2
-
- void sfir2d_(), simple_sfir2d_(), ornl_sfir2d_(), sfirm1d_(), scorm1d_();
- #define SIMPLE_FIR simple_sfir2d_
- #define SIMPLE_IIR simple_siir2d_
- #define SIMPLE_COR simple_scor2d_
- #define ORNL_FIR ornl_sfir2d_
- #define ORNL_IIR ornl_siir2d_
- #define ORNL_COR ornl_scor2d_
- #define MY_FIR sfir2d_
- #define MY_IIR siir2d_
- #define MY_COR scor2d_
- #define MY_C_FIR sfir2d
- #define MY_C_IIR siir2d
- #define MY_C_COR scor2d
- #define MY_M_FIR sfirm1d_
- #define MY_M_IIR siirm1d_
- #define MY_M_COR scorm1d_
- #define MY_INIT sinit_
- #define TOLERANCE 1.e-4
- #define THIS_IS_REAL
- #endif
- #ifdef DOUBLE /* real double precision */
-
- typedef double this_variable;
- typedef double this_real;
-
- #define OPS_PER_ITER 2
-
- void dfir2d_(), ornl_dfir2d_(), simple_dfir2d_(), dfirm1d_(), dcorm1d_();
- #define SIMPLE_FIR simple_dfir2d_
- #define SIMPLE_IIR simple_diir2d_
- #define SIMPLE_COR simple_dcor2d_
- #define ORNL_FIR ornl_dfir2d_
- #define ORNL_IIR ornl_diir2d_
- #define ORNL_COR ornl_dcor2d_
- #define MY_FIR dfir2d_
- #define MY_IIR diir2d_
- #define MY_COR dcor2d_
- #define MY_C_FIR dfir2d
- #define MY_C_IIR diir2d
- #define MY_C_COR dcor2d
- #define MY_M_FIR dfirm1d_
- #define MY_M_IIR diirm1d_
- #define MY_M_COR dcorm1d_
- #define MY_INIT dinit_
- #define TOLERANCE 1.e-10
- #define THIS_IS_REAL
-
- #endif
- #ifdef COMPLEX /* complex single precision */
-
- typedef complex this_variable;
- typedef float this_real;
-
- #define OPS_PER_ITER 8
-
- void cfir2d_(), ornl_cfir2d_(), simple_cfir2d_(), cfirm1d_(), ccorm1d_();
- #define SIMPLE_FIR simple_cfir2d_
- #define SIMPLE_IIR simple_ciir2d_
- #define SIMPLE_COR simple_ccor2d_
- #define ORNL_FIR ornl_cfir2d_
- #define ORNL_IIR ornl_ciir2d_
- #define ORNL_COR ornl_ccor2d_
- #define MY_FIR cfir2d_
- #define MY_IIR ciir2d_
- #define MY_COR ccor2d_
- #define MY_C_FIR cfir2d
- #define MY_C_IIR ciir2d
- #define MY_C_COR ccor2d
- #define MY_M_FIR cfirm1d_
- #define MY_M_IIR ciirm1d_
- #define MY_M_COR ccorm1d_
- #define MY_INIT cinit_
- #define TOLERANCE 1.e-4
- #define THIS_IS_COMPLEX
-
- #endif
- #ifdef ZOMPLEX /* complex double precision */
-
- typedef zomplex this_variable;
- typedef double this_real;
-
- #define OPS_PER_ITER 8
-
- void zfir2d_(), ornl_zfir2d_(), simple_zfir2d_(), zfirm1d_(), zcorm1d_();
- #define SIMPLE_FIR simple_zfir2d_
- #define SIMPLE_IIR simple_ziir2d_
- #define SIMPLE_COR simple_zcor2d_
- #define ORNL_FIR ornl_zfir2d_
- #define ORNL_IIR ornl_ziir2d_
- #define ORNL_COR ornl_zcor2d_
- #define MY_FIR zfir2d_
- #define MY_IIR ziir2d_
- #define MY_COR zcor2d_
- #define MY_C_FIR zfir2d
- #define MY_C_IIR ziir2d
- #define MY_C_COR zcor2d
- #define MY_M_FIR zfirm1d_
- #define MY_M_IIR ziirm1d_
- #define MY_M_COR zcorm1d_
- #define MY_INIT zinit_
- #define TOLERANCE 1.e-10
- #define THIS_IS_COMPLEX
-
- #endif
-
- this_real my_val[3] = {0., -.33, 1.};
-
- /* ---------- The rest is the same ---------------- */
-
- #define MAX_SIZE 33
- #define DEFAULT_TRIALS 99
- #define MAX_INC 5
- #define MAX_TIMES 3
-
-
- #define ABS(a) ( ((a)>0) ? (a) : -(a))
- #define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
-
- void (*simple_function)();
- void (*ornl_function)();
- void (*my_function)();
- void GetArguments();
-
- double check_this();
-
- int parallel;
- int is_random;
- int n_trials;
- int len = 4;
-
- int size, n_trials, n_times, i_error;
- int nf, ng, nh;
- int nfx, ngx, nhx, nfy, ngy, nhy;
- int ldf, nfx1, nfx2, nfy1, nfy2;
- int ldg, ngx1, ngx2, ngy1, ngy2;
- int ldh, nhx1, nhx2, nhy1, nhy2;
- int incf, incg, inch;
- this_variable *vx, *vy, *vz, *vt;
- this_variable alpha, beta;
-
- double t, x, y, z, u;
-
- main(argc,argv)
- int argc;
- char *argv[];
- {
- int i, j, k;
-
- /* ******************************************************* */
- GetArguments( argc, argv);
- /* ******************************************************* */
-
- i_error = 0;
-
- for( k = 0; k < n_trials ; k++) {
-
- get_values();
-
- #ifdef THIS_IS_REAL
- printf("%3d<>%1dx( (%3d,%3d)(%3d,%3d)(%3d,%3d) | (%3d,%3d)(%3d,%3d):(%3d,%3d)(%3d,%3d):(%3d,%3d)(%3d,%3d) | %5.2f, %5.2f ): ",
- k,n_times, nfx,nfy, ngx,ngy, nhx,nhy,
- nfx1,nfx2,nfy1,nfy2,
- ngx1,ngx2,ngy1,ngy2,
- nhx1,nhx2,nhy1,nhy2,
- alpha, beta );
- #endif
- #ifdef THIS_IS_COMPLEX
- printf("%3d<>%3dx( (%3d,%3d)(%3d,%3d)(%3d,%3d) | (%3d,%3d)(%3d,%3d):(%3d,%3d)(%3d,%3d):(%3d,%3d)(%3d,%3d) ): ",
- k,n_times, nfx,nfy, ngx,ngy, nhx,nhy,
- nfx1,nfx2,nfy1,nfy2,
- ngx1,ngx2,ngy1,ngy2,
- nhx1,nhx2,nhy1,nhy2 );
- #endif
- /*
- printf("%1dx(%3d,%3d,%3d | %2d,%3d,%3d | %2d,%3d,%3d | (%5.2f,%5.2f) | %2d,%3d,%3d | (%5.2f,%5.2f)): ",
- n_times, nf,ng,nh, incf,nf1,nf2, incg,ng1,ng2, alpha.real,alpha.imag, inch,nh1,nh2, beta.real,beta.imag);
- */
- fflush(stdout);
-
- vx = (this_variable *)my_malloc(((nf+1)) * sizeof( this_variable));
- vy = (this_variable *)my_malloc(((ng+1)) * sizeof( this_variable));
- vz = (this_variable *)my_malloc(((nh+1)) * sizeof( this_variable));
- vt = (this_variable *)my_malloc(((nh+1)) * sizeof( this_variable));
-
- if( (vx == (this_variable *)0) ||
- (vy == (this_variable *)0) ||
- (vt == (this_variable *)0) ||
- (vz == (this_variable *)0)) {
- fprintf( stderr, "Malloc problem ... Exiting");
- exit(0);
- }
- i = MY_INIT( &nf, vx);
- j = MY_INIT( &ng, vy);
-
- do_it();
-
- printf("\n", x);
-
- my_free ( vx);
- my_free ( vy);
- my_free ( vz);
- my_free ( vt);
- if( i_error)
- return (-i_error);
- }
- return (0);
- }
-
-
- do_it()
- {
- int ii, jj, k;
- int ifx1, ifx2, ify1, ify2;
- int igx1, igx2, igy1, igy2;
- int ihx1, ihx2, ihy1, ihy2;
- int this_ldf, this_ldg, this_ldh, inc;
- this_variable *this_vx, *this_vy, *this_vz, *this_vt;
- this_variable this_alpha, this_beta;
-
- /*
- * Checking against a simple convolution
- */
- #ifdef THIS_IS_REAL
- this_alpha = 1.0;
- this_beta = 0.0;
-
- vy[0] = 1.0;
- #endif
- #ifdef THIS_IS_COMPLEX
- this_alpha.real = 1.0;
- this_alpha.imag = 0.0;
- this_beta.real = 0.0;
- this_beta.imag = 0.0;
-
- vy[0].real = 1.0;
- vy[0].imag = 0.5;
- #endif
- inc = 1;
-
- ifx1 = 1; ifx2 = nfx;
- ify1 = 2; ify2 = nfy;
- igx1 = 0; igx2 = ngx;
- igy1 = 0; igy2 = ngy;
- ihx1 = ifx1+igx1; ihx2 = nfx+ngx-1;
- ihy1 = ify1+igy1; ihy2 = nfy+ngy-1;
- this_ldf= ifx2;
- this_ldg= igx2;
- this_ldh= ihx2;
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_FIR( vx,&inc,&this_ldf,&ifx1,&ifx2,&ify1,&ify2,
- vy,&inc,&this_ldg,&igx1,&igx2,&igy1,&igy2,
- vt,&inc,&this_ldh,&ihx1,&ihx2,&ihy1,&ihy2,
- &this_alpha,&this_beta);
- for( ii = 0; ii < n_times ; ii ++)
- SIMPLE_FIR( &ifx2, &ify2, &igx2, &igy2, vx, vy, vz);
-
- t = check_this( vz, vt, nh+1) ;
-
- /*
- * Checking IIR against a simple IIR_filter
- */
- ifx1 = 1; ifx2 = nfx;
- ify1 = 2; ify2 = nfy;
- igx1 = 1; igx2 = ngx;
- igy1 = 2; igy2 = ngy;
- ihx1 = ifx1-igx1; ihx2 = nfx+ngx-1;
- ihy1 = ify1-igy1; ihy2 = nfy+ngy-1;
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_IIR( vx,&inc,&this_ldf,&ifx1,&ifx2,&ify1,&ify2,
- vy,&inc,&this_ldg,&igx1,&igx2,&igy1,&igy2,
- vt,&inc,&this_ldf,&ihx1,&ifx2,&ihy1,&ify2);
- for( ii = 0; ii < n_times ; ii ++)
- SIMPLE_IIR( &ifx2, &ify2, &igx2, &igy2, vx, vy, vz);
-
- t = check_this( vz, vt, nh+1) ;
-
- /*
- * Checking COR against a simple corelation
- */
- ifx1 = 0; ifx2 = nfx-1;
- ify1 = 0; ify2 = nfy-1;
- igx1 = 0; igx2 = ngx-1;
- igy1 = 0; igy2 = ngy-1;
- ihx1 = ifx1-igx2; ihx2 = nfx+ngx-1;
- ihy1 = ify1-igy2; ihy2 = nfy+ngy-1;
- this_ldf= nfx;
- this_ldg= ngx;
- this_ldh= nfx+ngx-1;
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_COR( vx,&inc,&this_ldf,&ifx1,&nfx,&ify1,&nfy,
- vy,&inc,&this_ldg,&igx1,&ngx,&igy1,&ngy,
- vt,&inc,&this_ldh,&ihx1,&ihx2,&ihy1,&ihy2);
- for( ii = 0; ii < n_times ; ii ++)
- SIMPLE_COR( &nfx, &nfy, &ngx, &ngy, vx, vy, vz);
-
- t = check_this( vz, vt, nh+1) ;
-
- /*
- * Checking the Fortran version against a Fortran template
- */
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_FIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vz,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy,
- &alpha,&beta);
- for( ii = 0; ii < n_times ; ii ++)
- ORNL_FIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vt,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy,
- &alpha,&beta);
- t = check_this( vz, vt, nh+1) ;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_IIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vz,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy);
- for( ii = 0; ii < n_times ; ii ++)
- ORNL_IIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vt,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy);
- t = check_this( vz, vt, nh+1) ;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_COR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vz,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy);
- for( ii = 0; ii < n_times ; ii ++)
- ORNL_COR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vt,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy);
- t = check_this( vz, vt, nh+1) ;
- /*
- * Checking the C version against a Fortran version
- */
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_C_FIR( vx,incf,ldf,nfx1,nfx,nfy1,nfy,
- vy,incg,ldg,ngx1,ngx,ngy1,ngy,
- vt,inch,ldh,nhx1,nhx,nhy1,nhy,
- #ifdef THIS_IS_REAL
- alpha,beta);
- #endif
- #ifdef THIS_IS_COMPLEX
- &alpha,&beta);
- #endif
- for( ii = 0; ii < n_times ; ii ++)
- MY_FIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vz,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy,
- &alpha,&beta);
- t = check_this( vz, vt, nh+1) ;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_C_IIR( vx,incf,ldf,nfx1,nfx,nfy1,nfy,
- vy,incg,ldg,ngx1,ngx,ngy1,ngy,
- vt,inch,ldh,nhx1,nhx,nhy1,nhy);
- MY_IIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vz,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy);
- t = check_this( vz, vt, nh+1) ;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_C_COR( vx,incf,ldf,nfx1,nfx,nfy1,nfy,
- vy,incg,ldg,ngx1,ngx,ngy1,ngy,
- vt,inch,ldh,nhx1,nhx,nhy1,nhy);
- for( ii = 0; ii < n_times ; ii ++)
- MY_COR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&ngy1,&ngy,
- vz,&inch,&ldh,&nhx1,&nhx,&nhy1,&nhy);
- t = check_this( vz, vt, nh+1) ;
- /*
- * Checking Mulitple 1D Filters along First dimension
- */
- igy1 = 0;
- igy2 = 1;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_M_FIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy,
- vy,&incg,&ngx1,&ngx,
- vz,&inch,&ldh,&nhx1,&nhx,
- &alpha,&beta);
- for( ii = 0; ii < n_times ; ii ++)
- MY_FIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&igy1,&igy2,
- vt,&inch,&ldh,&nhx1,&nhx,&nfy1,&nfy,
- &alpha,&beta);
- t = check_this( vz, vt, nh+1) ;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_M_IIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy,
- vy,&incg, &ngx1,&ngx,
- vz,&inch,&ldh,&nhx1,&nhx);
- for( ii = 0; ii < n_times ; ii ++)
- MY_IIR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&igy1,&igy2,
- vt,&inch,&ldh,&nhx1,&nhx,&nfy1,&nfy);
- t = check_this( vz, vt, nh+1) ;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_M_COR( vx,&incf,&ldf,&nfx1,&nfx,&nfy,
- vy,&incg, &ngx1,&ngx,
- vz,&inch,&ldh,&nhx1,&nhx);
- for( ii = 0; ii < n_times ; ii ++)
- MY_COR( vx,&incf,&ldf,&nfx1,&nfx,&nfy1,&nfy,
- vy,&incg,&ldg,&ngx1,&ngx,&igy1,&igy2,
- vt,&inch,&ldh,&nhx1,&nhx,&nfy1,&nfy);
- t = check_this( vz, vt, nh+1) ;
- /*
- * Checking Mulitple 1D Filters along Second dimension
- */
- igx1 = 0;
- igx2 = 1;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_M_FIR( vx,&ldf,&incf,&nfy1,&nfy,&nfx,
- vy,&ldg, &ngy1,&ngy,
- vz,&ldh,&inch,&nhy1,&nhy,
- &alpha,&beta);
- for( ii = 0; ii < n_times ; ii ++)
- MY_FIR( vx,&incf,&ldf,&nfx1,&nfx ,&nfy1,&nfy,
- vy,&incg,&ldg,&igx1,&igx2,&ngy1,&ngy,
- vt,&inch,&ldh,&nfx1,&nfx ,&nhy1,&nhy,
- &alpha,&beta);
- t = check_this( vz, vt, nh+1) ;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_M_IIR( vx,&ldf,&incf,&nfy1,&nfy,&nfx,
- vy,&ldg, &ngy1,&ngy,
- vz,&ldh,&inch,&nhy1,&nhy);
- for( ii = 0; ii < n_times ; ii ++)
- MY_IIR( vx,&incf,&ldf,&nfx1,&nfx ,&nfy1,&nfy,
- vy,&incg,&ldg,&igx1,&igx2,&ngy1,&ngy,
- vt,&inch,&ldh,&nfx1,&nfx ,&nhy1,&nhy);
- t = check_this( vz, vt, nh+1) ;
-
- k = nh+1;
- MY_INIT( &k, vz);
- bcopy( vz, vt, (nh+1)*sizeof(this_variable));
- for( ii = 0; ii < n_times ; ii ++)
- MY_M_COR( vx,&ldf,&incf,&nfy1,&nfy,&nfx,
- vy,&ldg, &ngy1,&ngy,
- vz,&ldh,&inch,&nhy1,&nhy);
- for( ii = 0; ii < n_times ; ii ++)
- MY_COR( vx,&incf,&ldf,&nfx1,&nfx ,&nfy1,&nfy,
- vy,&incg,&ldg,&igx1,&igx2,&ngy1,&ngy,
- vt,&inch,&ldh,&nfx1,&nfx ,&nhy1,&nhy);
- t = check_this( vz, vt, nh+1) ;
- }
-
- void GetArguments( argc, argv)
- int argc;
- char *argv[];
- {
- int i, j, k;
- int nerror = 0;
-
- #define ON 1
-
- parallel = 0;
- is_random = 1;
- n_trials = DEFAULT_TRIALS;
-
- /* ******************************************************* */
- for ( i = 1 ; (i < argc) && (nerror != ON) ; i ++ ) {
- if( argv[i][0] == '-') {
- switch ( argv[i][1]) {
-
- case 'i' :
- case 'I' :
- is_random = 0;
- break;
- default : nerror = ON;
- }
- }
- else {
- if( i+1 > argc)
- nerror = ON;
- else {
- n_trials = atoi( argv[i]);
- }
- }
- }
- if( nerror == ON) {
- fprintf( stderr,
- "Usage : %s [-p(arallel)] [n_trials]\n", argv[0]);
- exit(0);
- }
- if( is_random)
- srandom( (123*getpid()) | 0x01);
- else
- srandom( 1);
- }
- get_values(){
- int jj;
- if( is_random) {
- nfx = random() % MAX_SIZE + 1;
- ngx = random() % MAX_SIZE + 1;
- nhx = nfx+ngx+random() % MAX_SIZE;
-
- nfx1 = random() % nfx;
- nfx2 = nfx1 + random() % (nfx - nfx1);
- ngx1 = random() % ngx;
- ngx2 = ngx1 + random() % (ngx - ngx1);
- nhx1 = nfx1+ngx1;
- nhx2 = nhx1 + random() % (nhx - nhx1);
-
- jj = random() % 23 - 11;
- nfx1 -= jj; nfx2 -= jj;
- jj = random() % 23 - 11;
- ngx1 -= jj; ngx2 -= jj;
- jj = random() % 23 - 11;
- nhx1 += jj; nhx2 += jj;
-
- nfy = random() % MAX_SIZE + 1;
- ngy = random() % MAX_SIZE + 1;
- nhy = nfy+ngy+random() % MAX_SIZE;
-
- nfy1 = random() % nfy;
- nfy2 = nfy1 + random() % (nfy - nfy1);
- ngy1 = random() % ngy;
- ngy2 = ngy1 + random() % (ngy - ngy1);
- nhy1 = nfy1+ngy1;
- nhy2 = nhy1 + random() % (nhy - nhy1);
-
- jj = random() % 23 - 11;
- nfy1 -= jj; nfy2 -= jj;
- jj = random() % 23 - 11;
- ngy1 -= jj; ngy2 -= jj;
- jj = random() % 23 - 11;
- nhy1 += jj; nhy2 += jj;
-
- incf = 1 + random() % MAX_INC;
- incg = 1 + random() % MAX_INC;
- inch = 1 + random() % MAX_INC;
-
- ldf = incf * nfx + random() % 3;
- ldg = incg * ngx + random() % 3;
- ldh = inch * nhx + random() % 3;
-
- nf = ldf * nfy;
- ng = ldg * ngy;
- nh = ldh * nhy;
-
- #ifdef THIS_IS_REAL
- alpha = my_val[random() % 3];
- beta = my_val[random() % 3];
- #endif
- #ifdef THIS_IS_COMPLEX
- alpha.real = my_val[random() % 3];
- alpha.imag = my_val[random() % 3];
- beta.real = my_val[random() % 3];
- beta.imag = my_val[random() % 3];
- #endif
- n_times = random() % MAX_TIMES + 1;
-
- }
- else {
- printf( "Enter sizex of f : ");
- scanf( "%d", &nfx);
- printf( "Enter sizey of f : ");
- scanf( "%d", &nfy);
- printf( "Enter sizex of g : ");
- scanf( "%d", &ngx);
- printf( "Enter sizey of g : ");
- scanf( "%d", &ngy);
-
- n_times = 1;
-
- nfx1 = 0; nfx2= nfx-1;
- nfy1 = 0; nfy2= nfy-1;
- ldf = nfx;
- nf = ldf * nfy;
-
- ngx1 = 0; ngx2= ngx-1;
- ngy1 = 0; ngy2= ngy-1;
- ldg = ngx;
- ng = ldg * ngy;
-
- printf( "Enter i0x of f : ");
- scanf( "%d", &nfx1);
- printf( "Enter i0y of f : ");
- scanf( "%d", &nfy1);
- printf( "Enter i0x of g : ");
- scanf( "%d", &ngx1);
- printf( "Enter i0y of g : ");
- scanf( "%d", &ngy1);
-
- nhx1 = 0; nhx2= nfx2+ngx2;
- nhy1 = 0; nhy2= nfy2+ngy2;
- nhx = nhx2-nhx1+1; nhy = nhy2-nhy1+1;
- ldh = nhx;
- nh = ldh * nhy;
-
- #ifdef THIS_IS_REAL
- alpha = my_val[1];
- beta = my_val[1];
- #endif
- #ifdef THIS_IS_COMPLEX
- alpha.real = my_val[1];
- alpha.imag = my_val[0];
- beta.real = my_val[0];
- beta.imag = my_val[1];
- #endif
- incf = 1;
- incg = 1;
- inch = 1;
- }
- }
-
- double check_this( this_variable *a, this_variable *b, int n)
- {
- double max, av;
- int i, nerr=0;
- max = av = 0.0;
-
- #ifdef THIS_IS_REAL
- for (i = 0; i < n; i++){
- t = a[i] - b[i];
- t = t * t;
- if( t > max) max = t;
- t = a[i];
- av += t * t;
- }
- #endif
- #ifdef THIS_IS_COMPLEX
- for (i = 0; i < n; i++){
- t = a[i].real - b[i].real;
- z = a[i].imag - b[i].imag;
- t = t * t + z * z;
- if( t > max) max = t;
- t = a[i].real;
- z = a[i].imag;
- av += t * t + z * z;
- }
- #endif
- max = sqrt(max);
- av = sqrt( av / (double)n);
- if( av > 0.0) {
- max = max / av;
- }
- if( max > TOLERANCE) {
- fprintf(stderr, " Difference with reference is %.12e \n\n", max);
- max = TOLERANCE * av;
- max = max * max;
- for (i = 0; i < n; i++){
- #ifdef THIS_IS_REAL
- t = a[i] - b[i];
- t = t * t;
- #endif
- #ifdef THIS_IS_COMPLEX
- t = a[i].real - b[i].real;
- z = a[i].imag - b[i].imag;
- t = t * t + z * z;
- #endif
- if( t > max) {
- if( nerr < 10)
- fprintf(stderr, " %d", i);
- nerr++;
- }
- }
- fprintf( stderr, "\n %d Errors detected \n", nerr);
- }
- else
- printf("-", t);
-
- fflush(stdout);
- i_error += nerr;
- return(max);
- }
-